<script>
import Vue from 'vue'
let dragEventBus = new Vue()
Vue.directive(
    'dragger', function (el, binding) {
      el.onmousedown = function (e) {
        e.preventDefault()
        e.stopPropagation()
        let x = e.pageX
        let y = e.pageY
        document.onmousemove = function (e) {
          let oX = e.pageX - x
          let oY = e.pageY - y
          dragEventBus.$emit('dragger-offset', {oX: oX, oY: oY, e: e})
        }
        document.onmouseup = function (e) {
          document.onmouseup = null
          document.onmousemove = null
          dragEventBus.$emit('dragger-end')
        }
      }
    }
)
export default dragEventBus
</script>
